﻿using BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InventoryMIS2019.Templates
{
    public partial class BaselnfoForm : Form
    {
        public Operation opera;//定义操作类型变量
        public BaselnfoForm()
        {
            InitializeComponent();
            opera = Operation.NONE;//默认操作为none(不可操作）
        }

        private void TemNew_Click(object sender, EventArgs e)
        {
            opera = Operation.INSERT;//定义操作为insert新增操作
            ClickEven("新增");
        }

        private void TemModify_Click(object sender, EventArgs e)
        {
            opera = Operation.UPDATE;
            ClickEven("修改");

        }

        private void TemDelete_Click(object sender, EventArgs e)
        {
            opera = Operation.DELETE;
            ClickEven("删除");

        }
        /// <summary>
        /// 处理按钮单击事件窗口可见性方法
        /// </summary>
        private void ClickEven(string opera=null )
        {
            if (opera == null || opera == "")
            {
                TemNew.Enabled = TemModify.Enabled = TemDelete .Enabled = true;//默认：新增、修改、删除按钮可操作
                Box1Tembaseinfo.Visible = false;//groupbox空间可见性为false
            }
            else
            {
                Box1Tembaseinfo.Visible = true;//groupbox空间可见性为true
                TemNew.Enabled = TemModify.Enabled = TemDelete.Enabled = false;//默认：新增、修改、删除按钮不可操作
                Box1Tembaseinfo.Text = opera + "处理";
            }
        }

        private void Temquxiao_Click(object sender, EventArgs e)
        {
            opera = Operation.NONE ;
            ClickEven();
            Clear();
        }
        /// <summary>
        /// 可继承性的方法
        /// 清空文本框输入
        /// </summary>
        protected void Clear()
        {
            foreach (Control item in Box1Tembaseinfo.Controls )
            {
                if (item is TextBox )
                {
                    item.Text = "";
                }
            }
        }
    }
}
